package VacationHomework.LeetCode;

public class Num258 {
    public int addDigits(int num) {
        //时间复杂度O(N)
        while (num>=10) {
            int sum=0;
            while (num!=0) {
                int ret = num % 10;
                sum += ret;
                num = num / 10;
            }
            num=sum;
        }
        return num;
    }
//    public int addDigits(int num) {
//        //时间复杂度O(1)
//        return (num-1)%10+1;
//
//    }

}
